import React from 'react';
import ReactDOM from 'react-dom';
import echarts from 'echarts';

export default React.createClass({
  contextTypes: {
    router: React.PropTypes.object
  },

  getInitialState() {
    return {
      template: '',
    }
  },

  componentDidMount() {
    this.reqwestData();
  },

  reqwestData() {
    let _me = this;
    let params = {
      id: 2,
      tpMap: {
        userId: 3,
      }

    };
    Utils.sendAjax({
      url: '/chartTemplate/view',
      data: JSON.stringify(params),
      callback: function (result) {
	if (result.code === '0000') {
	    _me.setState({
	      template: result.data,
	    })
	    _me.drawPie();
	} else {
	    // Message.error(result.message);
	}
      }
    })
  },

  drawPie() {
    var column = echarts.init(document.getElementById('column'));
    option = (new Function( "return " + this.state.template ))();
    column.setOption(option);
  },

    render () {
        return (
            <div  >
                <div id="column" className="column"></div>
            </div>
        );
    }
});
